#include "../include/gudb.h"
#include "../src/parser/sql_parser.h"
#include <stdio.h>
#include <stdlib.h>

int main() {
    printf("Testing tokenization of CREATE INDEX statement...\n");
    
    const char* sql = "CREATE INDEX idx_test ON users (id)";
    printf("SQL: %s\n", sql);
    
    // Create lexer
    lexer_t* lexer = lexer_create(sql);
    if (!lexer) {
        printf("Failed to create lexer\n");
        return 1;
    }
    
    // Tokenize and print all tokens
    token_t* token;
    int token_count = 0;
    while ((token = lexer_next_token(lexer)) != NULL && token->type != TOKEN_EOF) {
        printf("Token %d: Type=%d, Value='%s'\n", ++token_count, token->type, token->value ? token->value : "NULL");
        token_destroy(token);
        
        if (token_count > 20) { // Prevent infinite loop
            printf("Too many tokens, stopping\n");
            break;
        }
    }
    
    if (token) {
        token_destroy(token);
    }
    
    // Clean up
    lexer_destroy(lexer);
    
    return 0;
}